package com.ruoyi.keep.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.keep.domain.GymExperience;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.keep.service.IGymexperienceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 健身经验Controller
 * 
 * @author ruoyi
 * @date 2024-08-18
 */
@RestController
@RequestMapping("/keep/gymexperience")
public class GymexperienceController extends BaseController
{
    @Autowired
    private IGymexperienceService gymexperienceService;

    /**
     * 查询健身经验列表
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:list')")
    @GetMapping("/list")
    public TableDataInfo list(GymExperience gymexperience)
    {
        startPage();
        List<GymExperience> list = gymexperienceService.selectGymexperienceList(gymexperience);
        return getDataTable(list);
    }

    /**
     * 导出健身经验列表
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:export')")
    @Log(title = "健身经验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GymExperience gymexperience)
    {
        List<GymExperience> list = gymexperienceService.selectGymexperienceList(gymexperience);
        ExcelUtil<GymExperience> util = new ExcelUtil<GymExperience>(GymExperience.class);
        util.exportExcel(response, list, "健身经验数据");
    }

    /**
     * 获取健身经验详细信息
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(gymexperienceService.selectGymexperienceById(id));
    }

    /**
     * 新增健身经验
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:add')")
    @Log(title = "健身经验", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GymExperience gymexperience)
    {
        return toAjax(gymexperienceService.insertGymexperience(gymexperience));
    }

    /**
     * 修改健身经验
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:edit')")
    @Log(title = "健身经验", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GymExperience gymexperience)
    {
        return toAjax(gymexperienceService.updateGymexperience(gymexperience));
    }

    /**
     * 删除健身经验
     */
    @PreAuthorize("@ss.hasPermi('keep:gymexperience:remove')")
    @Log(title = "健身经验", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gymexperienceService.deleteGymexperienceByIds(ids));
    }
}
